﻿<style>
#content-right{
	margin:0 auto;
	width:820px;
}
.type1{float:none;}
#content-right,#info{clear:both;}
#add_new{background: url("<?php echo base_url()?>resources/images/btnAdd.png") no-repeat scroll 0 0 transparent;width:135px;height:30px;padding-top:20px;padding-left:15px;margin-bottom:5px;}
.box{width:330px;height: 70px;padding: 10px;margin:0 auto;margin-top:10px;}
.filter{float:left;clear:both;}
.box span{float:left;}
</style>
<script type="text/javascript">
 $(function() {
	$("input[name='rdfilter']").change(function(){
		$("#info").submit();
	});
	$("#txtsn").change(function(){
		if($("input[name='rdfilter']:checked").val()==1)
			$("#info").submit();
	});
	$("#txtinactive").change(function(){
		if($("input[name='rdfilter']:checked").val()==2)
			$("#info").submit();
	});
 });
 </script>
		<h1>Danh sách khách hàng</h1>
<div id="content-right" class="type1">
		<?php echo form_open(current_url(),"id='info'"); ?>	

<div class="box effect7">
<span><input type="radio" <?php echo $rdfilter==1?"checked":"";?> name="rdfilter" value="1">Sinh nhat<input value="<?php echo $txtsn;?>" size="3" name="txtsn" id="txtsn" /> ngay`</span>
<span><input type="radio" <?php echo $rdfilter==2?"checked":"";?> name="rdfilter" value="2">Khach hang ko thuong xuyen<input value="<?php echo $txtinactive;?>" size="3" name="txtinactive" id="txtinactive" /> tuan`</span>
<span><input type="radio" <?php echo $rdfilter==3?"checked":"";?> name="rdfilter" value="3">Tat ca</span>
</div>
<?php echo form_close(); ?>
		 <div id = "add_new">
				<?php  
                    if( isset( $action )){
                        foreach($action as $a){
                            if( strtolower($a['id']) == 'new'){
                                echo anchor( base_url( ) . $a['url'], $a['label'] );
                                break;
                            }
                        }
                    } 
                        
                ?>
			</div>


    <table border="0">
	<tr border="0">
	  <?php

                 foreach( $rules as $i ){
                    if( in_array( $i[ 'field_id' ], $master_limited  ) ){
						if(isset($i[ 'width' ]))
							$width = "width = '".$i[ 'width' ]."'";
						else
							$width = "";
                        echo "<th $width class='".$i['class']."' style='".$i['style']."'>". $i[ 'label' ]."</th>";
					}
                }
				
            ?>
			<th width="9%" class="last">Chức năng</th>
	</tr>
	<?php
                for( $i = 0; $i < count( $results ); $i++ ){
                    echo "<tr>";
					if($i%2==1) $odd="odd"; else $odd="";
                            foreach( $rules as $item ){
                           	    if( $item[ 'field_id' ] != "Image_ID" && in_array( $item[ 'field_id' ], $master_limited ) ){ 	
									$class_child=$item['class_child'];
         			                echo "<td class='$odd $class_child'>";
									if($item[ 'control' ] == "time")
										echo date("d/m/y",$results[ $i ][ $item[ 'field_id' ] ]);
									else if($item[ 'control' ] == "vnd") 
										echo formatcurrency($results[ $i ][ $item[ 'field_id' ] ] * 1000);
									else if($item[ 'control' ] == "percent") 
										echo $results[ $i ][ $item[ 'field_id' ] ]."%";
									else echo $results[ $i ][ $item[ 'field_id' ] ];
            						echo "</td>";					
								}
                            }
							echo "<td class='$odd c'>".$results[ $i ]['Edit'].' '.$results[ $i ]['Delete']."</td>";
                    echo "</tr>";
                }
            ?>
			<tr><td colspan="<?php echo count($rules)+1;?>"><center><div class="pagination"><?php echo $this->pagination->create_links(); ?></div></center></td></tr>
	</table>
</div>
	<div class="both"></div>
</div>
